import observe from "./observe";
import Watcher from "./Watcher";
import Compile from "./Compile";
export default class Vue {
  constructor(options) {
    this.$options = options;
    this._data = options.data();
    observe(this._data)
    this._initeWatch();
    this._initData();
    new Compile(options.el, this);
  }
  _initeWatch() {
    let watch = this.$options.watch;
  
    for (let key in watch) {
      new Watcher(this._data, key, watch[key]);
      console.log(this._data,key,'d');
    }
  }
  _initData() {
    let self = this;
    Object.keys(this._data).forEach((key) => {
      Object.defineProperty(self, key, {
        get() {
          return self._data[key];
        },
        set(val) {
          self._data[key] = val;
        },
      });
    });
  }
}
